package com.example.demo.warn.scheduler;

import cn.hutool.core.date.DateUtil;
import com.example.demo.model.component.MySQLComponent;
import com.example.demo.warn.service.WarnComponent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 预警定时任务
 *
 * @author yuanz
 * @date 2024/06/06
 */
@Slf4j
@Component
public class WarnSchedulerTask {

    @Autowired
    private WarnComponent warnComponent;

    @Async
//    @Scheduled(cron = "${warn-config.cron}", fixedRateString = "${warn-config.fixedRate}")
    public void warnBySpecialZoneAndFollowAndAttrCode() {
        log.info("------------开始调用【特定区域方向同归属地顺序被采预警】方法【{}】------------", DateUtil.now());
        warnComponent.warnBySpecialZoneAndFollowAndAttrCode(new Date());
        log.info("------------调用【特定区域方向同归属地顺序被采预警】方法结束【{}】------------", DateUtil.now());
    }

    @Async
//    @Scheduled(cron = "${warn-config.cron}", fixedRateString = "${warn-config.fixedRate}")
    public void warnBySpecialZoneAndFollowAndImsi() {
        log.info("------------开始调用【特定区域方向IMSI连续三点位出现预警】方法【{}】------------", DateUtil.now());
        warnComponent.warnBySpecialZoneAndFollowAndImsi(new Date());
        log.info("------------调用【特定区域方向IMSI连续三点位出现预警】方法结束【{}】------------", DateUtil.now());
    }

    @Async
//    @Scheduled(cron = "${warn-config.cron}", fixedRateString = "${warn-config.fixedRate}")
    public void warnBySpecialZoneAndAttrCode() {
        log.info("------------开始调用【特定区域同归属地再次被采预警】方法【{}】------------", DateUtil.now());
        warnComponent.warnBySpecialZoneAndAttrCode(new Date());
        log.info("------------调用【特定区域同归属地再次被采预警】方法结束【{}】------------", DateUtil.now());
    }

}
